<!-- 消息通知 -->
<script lang="ts" setup>
import { useInfoStore } from '../../stores/userInfo'
/**
 *表格栏位信息
 */
const columns = [
  {
    title: '编号',
    dataIndex: 'id',
  },
  {
    title: '通知类型',
    dataIndex: 'noteType',
  },
  {
    title: '通知类容',
    dataIndex: 'noteMessage',
  },
  {
    title: '状态',
    dataIndex: 'state',
  },
  {
    title: '操作',
    dataIndex: 'action',
  },
]

/**
 * pinia store
 */
const useInfo = useInfoStore()
</script>

<template>
  <div>
    <a-table :columns="columns" :dataSource="useInfo.noteInfo.noteList">
      <template #bodyCell="{ column, text, record }">
        <template v-if="column.dataIndex == 'state'">
          {{ record.state ? '已读' : '未读' }}
        </template>
        <template v-if="column.dataIndex == 'action' && record.state == false">
          <a-button type="primary" @click="useInfo.updatedNoteState(record.id)"
            >标为已读</a-button
          >
        </template>
      </template>
    </a-table>
  </div>
</template>

<style lang="scss" scoped></style>
